
<!-- aad service_principals -->
<script id="services.aad.service_principals.partial" type="text/x-handlebars-template">
    <div id="resource-name" class="list-group-item active">
        <h4 class="list-group-item-heading">{{name}}</h4>
    </div>
    <div class="list-group-item">
        <h4 class="list-group-item-heading">Information</h4>
        <div class="list-group-item-text item-margin">ID: <span id="aad.service_principals.{{@key}}.id"><samp>{{value_or_none id}}</samp></span></div>
        <div class="list-group-item-text item-margin">Tags: 
            {{#each tags}}
                <div
                    style="border-radius: 5px; -webkit-border-radius: 5px; float: center; background-color: #c2c2d6; padding: 0.1px; text-align: center; display: inline-flex;">
                    <samp>{{value_or_none this}}</samp>
                </div>&nbsp;&nbsp;
            {{else}}
                <div style="display: inline-flex;"><samp>None</samp></div>
            {{/each}}
        </div>
        <div class="list-group-item-text item-margin">Status: <span id="aad.service_principals.{{@key}}.account_enabled">{{convert_bool_to_enabled account_enabled}}</span></div>
        {{#if app_name}}
            <div class="list-group-item-text item-margin">App: <a href="javascript:showObject('services.aad.applications', 'app_id', '{{app_id}}')">{{value_or_none app_name}}</a></span></div>
        {{else}}
            <div class="list-group-item-text item-margin">App: {{value_or_none app_name}}</a></span></div>
        {{/if}}
        <div class="list-group-item-text item-margin">App Owner Tenant ID: <span id="aad.service_principals.{{@key}}.app_owner_tenant_id"><samp>{{value_or_none app_owner_tenant_id}}</samp></span></div>
        <div class="list-group-item-text item-margin">App Role Assignment Required: <span id="aad.service_principals.{{@key}}.app_role_assignment_required"><samp>{{value_or_none app_role_assignment_required}}</samp></span></div>
        <div class="list-group-item-text item-margin">Type: <span id="aad.service_principals.{{@key}}.object_type"><samp>{{value_or_none object_type}}</samp></span></div>
        <div class="list-group-item-text item-margin">Service Principal Type: <span id="aad.service_principals.{{@key}}.service_principal_type"><samp>{{value_or_none service_principal_type}}</samp></span></div>
        <div class="list-group-item-text item-margin">Publisher Name: <span id="aad.service_principals.{{@key}}.publisher_name"><samp>{{value_or_none publisher_name}}</samp></span></div>
        <div class="list-group-item-text item-margin">Deletion Timestamp: <span id="aad.service_principals.{{@key}}.deletion_timestamp"><samp>{{value_or_none deletion_timestamp}}</samp></span></div>
    </div>
    <div class="list-group-item">
        <h4 class="list-group-item-heading">Roles
            {{> count_badge count=roles.length}}
        </h4>
        <div class="accordion-inner">
            <ul>
                {{#each roles}}
                <li class="list-group-item-text"><a href="javascript:showObject('services.rbac.subscriptions.{{this.subscription_id}}.roles', 'id', '{{this.role_id}}')">{{getValueAt 'services.rbac.subscriptions' this.subscription_id 'roles' this.role_id 'name'}}</a> (subscription <samp>{{this.subscription_id}}</samp>)</li></a></li>
                {{/each}}
            </ul>
        </div>
    </div>
    <div class="list-group-item">
        <h4 class="list-group-item-heading">Keys
            {{> count_badge count=key_credentials.length}}
        </h4>
        <div class="accordion-inner">
            <ul>
                {{#each key_credentials}}
                <li class="list-group-item-text">ID: <samp>{{value_or_none this.key_id}}</samp></li>
                <ul>
                    <li class="list-group-item-text">Type: <samp>{{value_or_none this.type}}</samp></li>
                    <li class="list-group-item-text">Usage: <samp>{{value_or_none this.usage}}</samp></li>
                    <li class="list-group-item-text">Start Date: {{format_date this.start_date}}</li>
                    <li class="list-group-item-text">End Date: {{format_date this.end_date}}</li>
                </ul>
                {{/each}}
            </ul>
        </div>
    </div>
</script>

<script>
    Handlebars.registerPartial("services.aad.service_principals", $("#services\\.aad\\.service_principals\\.partial").html());
</script>

<!-- Single aad service_principal template -->
<script id="single_aad_service_principal-template" type="text/x-handlebars-template">
    {{> modal-template template='services.aad.service_principals'}}
</script>
<script>
    var single_aad_service_principal_template = Handlebars.compile($("#single_aad_service_principal-template").html());
</script>
